package org.facilscrum.persistencia;

import org.facilscrum.beans.Issuescomentarios;
import java.sql.Date; 
import org.facilscrum.beans.*;
import org.facilscrum.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.facilscrum.generales.Mensajeria;
import org.facilscrum.generales.DataGManager;


/**
*
* @author
*/

public class IssuescomentariosPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/facilscrum/properties/mensajes");
static DataGManager dataGManager;
static List<Issuescomentarios> list;

public IssuescomentariosPersistencia(){
         esMensaje =false;
}



/**
*
* insert()
*/

public static boolean insert (Issuescomentarios issuescomentarios ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into issuescomentarios(idissues,comentario,username,fecha,hora)  values(?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setInt(1,issuescomentarios.getIdissues());
        pinsert.setString(2,issuescomentarios.getComentario());
        pinsert.setString(3,issuescomentarios.getUsername());
        pinsert.setDate(4,issuescomentarios.getFecha());
        pinsert.setString(5,issuescomentarios.getHora());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Issuescomentarios issuescomentarios ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update issuescomentarios set  idissues=?, comentario=?, username=?, fecha=?, hora=?  where  idissuescomentario ='"+issuescomentarios.getIdissuescomentario()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,issuescomentarios.getIdissues());
pupdate.setString(2,issuescomentarios.getComentario());
pupdate.setString(3,issuescomentarios.getUsername());
pupdate.setDate(4,issuescomentarios.getFecha());
pupdate.setString(5,issuescomentarios.getHora());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  issuescomentarios set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Issuescomentarios issuescomentarios_old , Issuescomentarios issuescomentarios) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update issuescomentarios set  idissuescomentario=?  where  idissuescomentario ='"+issuescomentarios_old.getIdissuescomentario()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(0,issuescomentarios.getIdissuescomentario());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Issuescomentarios issuescomentarios ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from issuescomentarios  where  idissuescomentario = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setInt(1,issuescomentarios.getIdissuescomentario());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from issuescomentarios where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from issuescomentarios  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Issuescomentarios issuescomentarios) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from issuescomentarios where idissuescomentario='"+issuescomentarios.getIdissuescomentario()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Issuescomentarios findByPrimaryKey(Issuescomentarios issuescomentarios) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from issuescomentarios where idissuescomentario='"+issuescomentarios.getIdissuescomentario()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
   issues2 =  issuesController.findByPrimaryKey(issues);
   if (issues2== null) {
       //no existe registro con ese codigo 
   } else {
   issues= issues2;
   issuescomentarios.setIssues(issues);
     }
   usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
   if (usuarios2== null) {
       //no existe registro con ese codigo 
   } else {
   usuarios= usuarios2;
   issuescomentarios.setUsuarios(usuarios);
     }
            issuescomentarios.setIdissuescomentario(rs.getInt("idissuescomentario"));
issuescomentarios.setIdissues(rs.getInt("idissues"));
issuescomentarios.setComentario(rs.getString("comentario"));
issuescomentarios.setUsername(rs.getString("username"));
issuescomentarios.setFecha(rs.getDate("fecha"));
issuescomentarios.setHora(rs.getString("hora"));
    }
    rs.close();
    psquery.close();
 return issuescomentarios;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByIdissuescomentario()
*/

public static List<Issuescomentarios> findByIdissuescomentario(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where idissuescomentario='"+issuescomentarios.getIdissuescomentario()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByIdissues()
*/

public static List<Issuescomentarios> findByIdissues(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where idissues='"+issuescomentarios.getIdissues()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByComentario()
*/

public static List<Issuescomentarios> findByComentario(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where comentario='"+issuescomentarios.getComentario()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByUsername()
*/

public static List<Issuescomentarios> findByUsername(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where username='"+issuescomentarios.getUsername()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByFecha()
*/

public static List<Issuescomentarios> findByFecha(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where fecha='"+issuescomentarios.getFecha()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* findByHora()
*/

public static List<Issuescomentarios> findByHora(Issuescomentarios issuescomentarios,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
      String sql = "select * from issuescomentarios where hora='"+issuescomentarios.getHora()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Issuescomentarios> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<>();
  String sql = "select * from issuescomentarios";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* Double func(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from issuescomentarios";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from issuescomentarios where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from issuescomentarios";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
     rs.beforeFirst();
     while (rs.next()) {
      x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from issuescomentarios where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return 0;
}


/**
*
* query()
*/

public static List<Issuescomentarios> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
  String sql = "select * from issuescomentarios where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* orderby()
*/

public static List<Issuescomentarios> orderby(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<>();
  String sql = "select * from issuescomentarios order by " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
}


/**
*
* getListRecords()
*/

public static List<Issuescomentarios> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<>();
  String sql = "select * from issuescomentarios";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "issuescomentarios" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
Issues issues = new Issues();
Issues issues2 = new Issues();
IssuesController issuesController = new IssuesController();
Usuarios usuarios = new Usuarios();
Usuarios usuarios2 = new Usuarios();
UsuariosController usuariosController = new UsuariosController();
        Issuescomentarios issuescomentarios2 = new Issuescomentarios(
         rs.getInt("idissuescomentario"),rs.getInt("idissues"),rs.getString("comentario"),rs.getString("username"),rs.getDate("fecha"),rs.getString("hora"));
            
    issues.setIdissues(rs.getInt("idissues"));
    usuarios.setUsername(rs.getString("username"));
            
  if(withRelation){
     issues2 =  issuesController.findByPrimaryKey(issues);
     if (issues2== null) {
       //not found records 
     } else {
     issues= issues2;
     issuescomentarios2.setIssues(issues);
       }
   }
  if(withRelation){
     usuarios2 =  usuariosController.findByPrimaryKey(usuarios);
     if (usuarios2== null) {
       //not found records 
     } else {
     usuarios= usuarios2;
     issuescomentarios2.setUsuarios(usuarios);
       }
   }
       list.add(issuescomentarios2);
    }
    rs.close();
    psquery.close();
    return list;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return null;
 }


}
